using System;
using System.Collections.Generic;
using System.Text;
using System.Data.OleDb;
using System.Data;
namespace QuanLyThuVien1.DAO
{
    class KETNOI
    {
        public static OleDbConnection taoKetNoi()
        {
            string m_sConnect = "Provider= Microsoft.ACE.OLEDB.12.0;Data Source = QuanLyThuVien.accdb";
            OleDbConnection m_OleDBCKetNoi = new OleDbConnection(m_sConnect);
            m_OleDBCKetNoi.Open();
            return m_OleDBCKetNoi;
        }
        public static DataTable NonQuery(String query)
        {
            string sKetNoi = "Provider= Microsoft.ACE.OLEDB.12.0;Data Source = QuanLyThuVien.accdb";
            OleDbConnection ODCKetNoiDuLieu = new OleDbConnection(sKetNoi);
            ODCKetNoiDuLieu.Open();
            DataTable DTTable = new DataTable();
            OleDbDataAdapter ODAAdapter;
            ODAAdapter = new OleDbDataAdapter(query, ODCKetNoiDuLieu);
            ODAAdapter.Fill(DTTable);
            ODCKetNoiDuLieu.Close();
            if (DTTable.Rows.Count == 0)
                return null;

            return DTTable;
        }
    }
}
